package com.crawData.controller;


import com.crawData.service.CrawDataManagerService;
import com.crawData.service.CrawDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;


@RestController
@RequestMapping("douyin/")
@Api(tags = "抖音数据爬取管理")
@Slf4j
public class CrawDataDouYinController {


    @Autowired
    private CrawDataManagerService crawDataManagerService;

    @Autowired
    private CrawDataService crawDataService;

    /**
     * 打开抖音博主视频主页
     * @return
     */
    @PostMapping("openDouYinIndex")
    @ApiOperation(value = "打开抖音博主视频主页")
    public String openDouYinIndex(@RequestBody HashMap<String,String> parms) {
        return crawDataService.openCrawlIndex(parms);
    }




    /**
     * 爬取抖音数据
     * @param parms
     * @return
     */
    @PostMapping("crawDataDouYin")
    @ApiOperation(value = "爬取抖音数据")
    public String crawData(@RequestBody HashMap<String,String> parms) {
        Object crawl = crawDataService.crawl(parms);
        if (crawl == null) {
            return "fail";
        }
        return "success";
    }


}
